package task1and3;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

public class WorkerTest extends Worker {

    public static void main(String[] args) {
        //1.定义List集合，在集合中增加如下三个员工基本信息
        //“凤姐” 18 20000 “欧阳锋” 60 8000 “刘德华” 40 30000
        List<Worker> l1 = new ArrayList<>();
        l1.add(new Worker("凤姐", 18, 20000));
        l1.add(new Worker("欧阳锋", 60, 8000));
        l1.add(new Worker("刘德华", 40, 30000));
        //2.在“欧阳锋”之前插入一个如下员工信息
        //“张柏芝” 35 3300
        l1.add(1, new Worker("张柏芝", 35, 3300));
        //3.删除“刘德华”信息
        l1.remove(3);
        //4.利用for循环遍历，打印List中所有员工的信息
        for (int i = 0; i < l1.size(); i++) {
            System.out.println(l1.get(i));
        }
        System.out.println("--------------------------------------------------");
        for (Object o : l1) {
            System.out.println(o);
        }
        System.out.println("--------------------------------------------------");
        //5.利用迭代遍历，对List中所有的员工调用work方法
        Iterator it = l1.iterator();
        while(it.hasNext()) {
            Worker w1 = (Worker) it.next();
            w1.work();
        }
    }
}

